package name.zxw.rabbitmq.priority;

import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

/**
 * 消费者
 *
 * @author zhangxinwang
 * @date 2022/6/22 15:49
 */
public class MyConsumer {


    public static void main(String[] args) throws Exception {
        String exchangeName = "priority";

        ConnectionFactory factory = new ConnectionFactory();
        Connection connection = factory.newConnection();
        Channel channel = connection.createChannel();


        //Publisher

        System.out.println("等待接收消息...");
        channel.basicConsume("console", true,
                (consumerTag, message) -> {
                    System.out.println("new String(message.getBody()) = " + new String(message.getBody()));
                    channel.basicAck(message.getEnvelope().getDeliveryTag(),false);
                },
                (consumerTag) -> {
                }
        );


    }


}
